export function loginAccount(userName, password) {
	var param = {
		userName: userName,
		password: password
	}
	var loginLog = {};
	const appBaseInfo = uni.getAppBaseInfo()
	var info = uni.getSystemInfoSync()
	var accountInfo={miniProgram:{envVersion:"",version:''}};
	
	
	// #ifdef APP-PLUS || MP-ALIPAY || MP-WEIXIN
			 accountInfo = uni.getAccountInfoSync();
	 // #endif
		accountInfo = accountInfo['miniProgram']

	var location=uni.getStorageSync("location") | "";
	loginLog['location']=location
	loginLog['myEvnVersion'] = accountInfo['envVersion'];

	loginLog['myVersion'] = accountInfo['version'];

	loginLog['myLanguage'] = uni.getStorageSync("lang") || info['language'];



	loginLog['terminal'] = 3;

	loginLog['brand'] = info['brand'];

	loginLog['model'] = info['model'];

	loginLog['language'] = info['language'];

	loginLog['version'] = info['version'];

	loginLog['systemVersion'] = info['system'];


	loginLog['platform'] = info['platform'];
	loginLog['theme'] = appBaseInfo['theme'];



	//	console.log("INFO", info)
	loginLog["grant_type"] = 'wechat'
	param['master'] = "xxxxx";
	param['loginLog'] = loginLog;
	param['parentUserId'] = uni.getStorageSync("parentUserId") || null
	//console.log(param, accountInfo, appBaseInfo,accountInfo)
	var url = 'oauth/login/accountWechat';
	// #ifdef H5
//	url = 'oauth/login/wxTest';
	// #endif
	return uni.$u.http.post(url, param);


}


//wxRegesterMini


export function regesterLogin(param,regesterInfo) {
	var loginLog = {};
	const appBaseInfo = uni.getAppBaseInfo()
	var info = uni.getSystemInfoSync()
	var accountInfo={miniProgram:{envVersion:"",version:''}};


// #ifdef APP-PLUS || MP-ALIPAY || MP-WEIXIN
		 accountInfo = uni.getAccountInfoSync();
 // #endif
	accountInfo = accountInfo['miniProgram']

	var location=uni.getStorageSync("location") | "";
	loginLog['location']=location
	loginLog['myEvnVersion'] = accountInfo['envVersion'];

	loginLog['myVersion'] = accountInfo['version'];

	loginLog['myLanguage'] = uni.getStorageSync("lang") || info['language'];



	loginLog['terminal'] = 3;

	loginLog['brand'] = info['brand'];

	loginLog['model'] = info['model'];

	loginLog['language'] = info['language'];

	loginLog['version'] = info['version'];

	loginLog['systemVersion'] = info['system'];


	loginLog['platform'] = info['platform'];
	loginLog['theme'] = appBaseInfo['theme'];



	//	console.log("INFO", info)
	loginLog["grant_type"] = 'wechat'
	param['master'] = "xxxxx";
	param['loginLog'] = loginLog;
	param['regesterInfo']=regesterInfo;


	//console.log(param, accountInfo, appBaseInfo,accountInfo)
	var url = 'oauth/login/wxRegesterMini';
	
	return uni.$u.http.post(url, param);


}

export function loginAccoundMini(param) {
	var loginLog = {};
	const appBaseInfo = uni.getAppBaseInfo()
	var info = uni.getSystemInfoSync()
	var accountInfo={miniProgram:{envVersion:"",version:''}};


// #ifdef APP-PLUS || MP-ALIPAY || MP-WEIXIN
		 accountInfo = uni.getAccountInfoSync();
 // #endif
	accountInfo = accountInfo['miniProgram']


	var location=uni.getStorageSync("location") | "";
	loginLog['location']=location
	loginLog['myEvnVersion'] = accountInfo['envVersion'];

	loginLog['myVersion'] = accountInfo['version'];

	loginLog['myLanguage'] = uni.getStorageSync("lang") || info['language'];


	//loginLog['location'] = "";
	loginLog['terminal'] = 3;

	loginLog['brand'] = info['brand'];

	loginLog['model'] = info['model'];

	loginLog['language'] = info['language'];

	loginLog['version'] = info['version'];

	loginLog['systemVersion'] = info['system'];


	loginLog['platform'] = info['platform'];
	loginLog['theme'] = appBaseInfo['theme'];



	//	console.log("INFO", info)
	loginLog["grant_type"] = 'wechat'
	param['master'] = "xxxxx";
	param['loginLog'] = loginLog;



	//console.log(param, accountInfo, appBaseInfo,accountInfo)
	var url = 'oauth/login/accountWechatMini';
	
	
	// #ifdef H5
	url = 'oauth/login/accountWechat';
	// #endif
	
	return uni.$u.http.post(url, param);


}

export function loginAccoundMiniOpen(param) {
	var loginLog = {};
	const appBaseInfo = uni.getAppBaseInfo()
	var info = uni.getSystemInfoSync()
	var accountInfo={miniProgram:{envVersion:"",version:''}};


// #ifdef APP-PLUS || MP-ALIPAY || MP-WEIXIN
		 accountInfo = uni.getAccountInfoSync();
 // #endif
	accountInfo = accountInfo['miniProgram']

	var location=uni.getStorageSync("location") | "";
	loginLog['location']=location
	loginLog['myEvnVersion'] = accountInfo['envVersion'];

	loginLog['myVersion'] = accountInfo['version'];

	loginLog['myLanguage'] = uni.getStorageSync("lang") || info['language'];


	//loginLog['location'] = "";
	loginLog['terminal'] = 3;

	loginLog['brand'] = info['brand'];

	loginLog['model'] = info['model'];

	loginLog['language'] = info['language'];

	loginLog['version'] = info['version'];

	loginLog['systemVersion'] = info['system'];


	loginLog['platform'] = info['platform'];
	loginLog['theme'] = appBaseInfo['theme'];



	//	console.log("INFO", info)
	loginLog["grant_type"] = 'wechat'
	param['master'] = "xxxxx";
	param['loginLog'] = loginLog;



	//console.log(param, accountInfo, appBaseInfo,accountInfo)
	var url = 'oauth/login/accountWechatMiniOpen';

	//var url = 'oauth/login/accountWechat';

	return uni.$u.http.post(url, param);


}


export function login(param={master:"",loginLog:{}}) {
	var loginLog = {};
	const appBaseInfo = uni.getAppBaseInfo()
	var info = uni.getSystemInfoSync()
	var accountInfo={miniProgram:{envVersion:"",version:''}};


// #ifdef APP-PLUS || MP-ALIPAY || MP-WEIXIN
		 accountInfo = uni.getAccountInfoSync();
 // #endif
	accountInfo = accountInfo['miniProgram']

	var location=uni.getStorageSync("location") | "";
	loginLog['location']=location
	loginLog['myEvnVersion'] = accountInfo['envVersion'];

	loginLog['myVersion'] = accountInfo['version'];

	loginLog['myLanguage'] = uni.getStorageSync("lang") || info['language'];


	//loginLog['location'] = "";
	loginLog['terminal'] = 3;

	loginLog['brand'] = info['brand'];

	loginLog['model'] = info['model'];

	loginLog['language'] = info['language'];

	loginLog['version'] = info['version'];

	loginLog['systemVersion'] = info['system'];


	loginLog['platform'] = info['platform'];
	loginLog['theme'] = appBaseInfo['theme'];



	//	console.log("INFO", info)
	loginLog["grant_type"] = 'wechat'
//	param['master'] = "xxxxx";
	param['loginLog'] = loginLog;
	param['parentUserId'] = uni.getStorageSync("parentUserId") || null
	//console.log(param, accountInfo, appBaseInfo,accountInfo)
	var url = 'oauth/login/wxMini';
	// #ifdef H5
	url = 'oauth/login/wxTest';
	// #endif
	return uni.$u.http.post(url, param);


}

export function refreshLogin() {

	var url = 'oauth/login/refreshLogin';

	return uni.$u.http.post(url);


}
//refreshLogin

export function byPhone(phone) {

	var url = 'oauth/login/byPhone?phone='+phone;

	return uni.$u.http.get(url);


}

export function byIdCard(idcard) {

	var url = 'oauth/login/byIdCard?idcard='+idcard;

	return uni.$u.http.get(url);


}

//wxMiniAuto
export function wxMiniAuto(code="") {
	var param={code:code};
	var loginLog = {};
	const appBaseInfo = uni.getAppBaseInfo()
	var info = uni.getSystemInfoSync()
	var accountInfo={miniProgram:{envVersion:"",version:''}};


// #ifdef APP-PLUS || MP-ALIPAY || MP-WEIXIN
		 accountInfo = uni.getAccountInfoSync();
 // #endif
	accountInfo = accountInfo['miniProgram']

	var location=uni.getStorageSync("location") | "";
	loginLog['location']=location
	loginLog['myEvnVersion'] = accountInfo['envVersion'];

	loginLog['myVersion'] = accountInfo['version'];

	loginLog['myLanguage'] = uni.getStorageSync("lang") || info['language'];


	//loginLog['location'] = "";
	loginLog['terminal'] = 3;

	loginLog['brand'] = info['brand'];

	loginLog['model'] = info['model'];

	loginLog['language'] = info['language'];

	loginLog['version'] = info['version'];

	loginLog['systemVersion'] = info['system'];


	loginLog['platform'] = info['platform'];
	loginLog['theme'] = appBaseInfo['theme'];



	//	console.log("INFO", info)
	loginLog["grant_type"] = 'wechat'
	param['master'] = "xxxxx";
	param['loginLog'] = loginLog;
	param['parentUserId'] = uni.getStorageSync("parentUserId") || null
	//console.log(param, accountInfo, appBaseInfo,accountInfo)
	var url = 'oauth/login/wxMiniAuto';
	return uni.$u.http.post(url, param);


}

//wxMiniCreate
export function wxMiniCreate(code="") {
	var param={code:code};
	var loginLog = {};
	const appBaseInfo = uni.getAppBaseInfo()
	var info = uni.getSystemInfoSync()
	var accountInfo={miniProgram:{envVersion:"",version:''}};


// #ifdef APP-PLUS || MP-ALIPAY || MP-WEIXIN
		 accountInfo = uni.getAccountInfoSync();
 // #endif
	accountInfo = accountInfo['miniProgram']


	var location=uni.getStorageSync("location") | "";
	loginLog['location']=location
	loginLog['myEvnVersion'] = accountInfo['envVersion'];

	loginLog['myVersion'] = accountInfo['version'];

	loginLog['myLanguage'] = uni.getStorageSync("lang") || info['language'];


	loginLog['terminal'] = 3;

	loginLog['brand'] = info['brand'];

	loginLog['model'] = info['model'];

	loginLog['language'] = info['language'];

	loginLog['version'] = info['version'];

	loginLog['systemVersion'] = info['system'];


	loginLog['platform'] = info['platform'];
	loginLog['theme'] = appBaseInfo['theme'];



	//	console.log("INFO", info)
	loginLog["grant_type"] = 'wechat'
	param['master'] = "xxxxx";
	param['loginLog'] = loginLog;
	param['parentUserId'] = uni.getStorageSync("parentUserId") || null
	//console.log(param, accountInfo, appBaseInfo,accountInfo)
	var url = 'oauth/login/wxMiniCreate';
	return uni.$u.http.post(url, param);


}

